﻿using System;
using System.Collections.Generic;
using System.Text;
using WHC.Hotel.Entity;

namespace WHC.Hotel.BLL
{
    public class Manufacture : BaseBLL<ManufactureInfo>
    {
        public Manufacture() : base()
        {
        }

        /// <summary>
        /// 如果目标不存在则插入，否则判断更新时间，如果目标较旧则更新
        /// </summary>
        /// <param name="infoList"></param>
        public void InsertOrUpdate(List<ManufactureInfo> infoList)
        {
            if (infoList != null && infoList.Count > 0)
            {
                foreach (ManufactureInfo info in infoList)
                {
                    ManufactureInfo tempInfo = baseDal.FindByID(info.ID);
                    if (tempInfo != null)
                    {
                        if (tempInfo.LastUpdated < info.LastUpdated)
                        {
                            baseDal.Update(info, info.ID.ToString());
                        }
                    }
                    else
                    {
                        baseDal.Insert(info);
                    }
                }
            }
        }
    }
}
